﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NETCORE.Autofac.Service;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace NETCORE.Autofac.Controllers
{
    [Route("api/[controller]")]
    public class PersonController : Controller
    {

        private IPersonService _personService;

        //通过构造函数注入Service
        public PersonController(IPersonService personService)
        {
            this._personService = personService;
        }

        [Route("Eat")]
        [HttpGet]
        public JsonResult Eat()
        {
            var eatRes = this._personService.Eat();

            return new JsonResult(new { eat = eatRes });
        }
    }
}
